package com.wn.service;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * @author yellow Docter
 * @date 2022 -08-31
 * @desc
 */
@SpringBootApplication
public class RabbitMQApplication {

    public static void main(String[] args) {

        SpringApplication.run(RabbitMQApplication.class,args);

    }

    //代码创建队列的操作

    /**
     *  创建一个队列 添加ioc容器中
     *  01 通过 queueBuild来创建
     *  02 durable("队列的名称")
     * @return
     */
    @Bean("createQueue")
    public Queue createQueue(){
        Queue build = QueueBuilder.durable("hello-queue1").build();
        return build;
    }

    @Bean("createQueue2")
    public Queue createQueue2(){
        Queue build = QueueBuilder.durable("hello-queue2").build();
        return build;
    }

    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
}
